package com.elvin.zoe.parser.sms;

import java.util.ArrayList;
import java.util.List;

import com.elvin.zoe.parser.AbstractParser;
import com.elvin.zoe.pojo.Message;
import com.elvin.zoe.pojo.SmsMessage;

public abstract class SmsParser extends AbstractParser {


    protected List<Message> parseMessagesFromTokens(List<String> messageTokens) throws Exception {
        List<Message> messages = new ArrayList<Message>();
        for (String messageToken : messageTokens) {
            int type = getMessageType(messageToken);
            String datetimeFormat = getMessageDatetimeFormat();
            String datetime = getMessageDatetime(messageToken);
            String text = getMessageText(messageToken);
            String imageName = getMessageImageName(messageToken);
            messages.add(new SmsMessage(type, datetime, datetimeFormat, text, imageName));
        }
        return messages;
    }


    protected abstract String getMessageImageName(String messageToken);

    protected abstract String getMessageText(String messageToken);


}
